<?php

namespace App\Policies;

use App\Document;
use App\Models\AdminUser;
use Illuminate\Auth\Access\HandlesAuthorization;

class DocumentPolicy
{
    use HandlesAuthorization;

    public function destroy(AdminUser $user, Document $model): bool
    {
        return $user['id'] == 1
            || $user['id'] == $model['creator_id']
            || $user['role_type'] == 1
            || ($user['role_type'] == 2 && $user['department_id'] == $model['department_id']);
    }
}
